/**
 * @format
 * @Author: TC
 * @Date: 2023-08-19 12:42:13
 * @Last Modified by: TC
 * @Last Modified time: 2025-05-05 01:37:23
 */

import { EventTouch, _decorator } from "cc";
import { app } from "../../App";
import { BaseComponent } from "../../Module/Component/BaseComponent";

const { ccclass, property } = _decorator;

/**
 * 可拖拽的单位
 */
@ccclass("DragItem")
export class DragItem extends BaseComponent {
    protected addUIEvent(): void {
        super.addUIEvent();
        // app..addTouchEvent(this, this.onTouchStart, this.onTouchMove, this.onTouchEnd);
    }

    /**
     * 触摸开始
     * @param e
     */
    protected onTouchStart(e: EventTouch): void {}

    /**
     * 触摸移动
     * @param e
     */
    protected onTouchMove(e: EventTouch): void {
        let delta = e.getDelta();
        this.node.setPosition(this.node.position.add3f(delta.x, delta.y, 0));
    }

    /**
     * 触摸结束
     * @param e
     */
    protected onTouchEnd(e: EventTouch): void {}
}
